!function(){tinymce.create("tinymce.plugins.codesyntax",{init:function(e,t){e.addCommand("mceSyntaxHL",function(){e.windowManager.open({title:"插入代码",file:t+"/dialog.htm",width:520,height:350})}),e.addCommand("toggleCode",function(){var t,n=e.selection.getNode(),o=e.selection.getContent(),i=e.selection.getBookmark();try{t=$.trim($(o).text())}catch(d){}t||(t=$.trim(o)),t?"PRE"==n.nodeName?$(n).replaceWith("<p>"+$(n).html()+"</p>"):e.insertContent("<pre>"+t+"</pre>"):$(n).replaceWith("PRE"==n.nodeName?"<p>"+$(n).html().replace(/\n/g,"<br />")+"</p>":"<pre>"+$(n).html()+"</pre>"),e.selection.moveToBookmark(i)}),e.addButton("codesyntax",{title:"插入代码",cmd:"mceSyntaxHL",image:t+"/img/file-xml.png"}),e.addButton("toggleCode",{title:"文本<->代码切换",cmd:"toggleCode",icon:"code"}),e.addShortcut("ctrl+shift+c","","toggleCode"),e.addShortcut("command+shift+c","","toggleCode"),e.on("keydown",function(t){var n=t.which?t.which:t.keyCode;return 9==n?(e.execCommand(t.shiftKey?"Outdent":"Indent"),t.preventDefault(),t.stopPropagation(),!1):void 0})},createControl:function(){return null}}),tinymce.PluginManager.add("codesyntax",tinymce.plugins.codesyntax)}();